package com.leagueoflegends.controller;

import com.leagueoflegends.bean.ChampionSpell;
import com.leagueoflegends.service.ChampionSpellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@CrossOrigin
@Controller
@RequestMapping("/spell")
public class ChampionSpellController {

    @Autowired
    ChampionSpellService championSpellService;

    @RequestMapping("/ins")
    public String insert(@RequestBody ChampionSpell spell) {
        championSpellService.insert(spell);
        return "";
    }

    @RequestMapping("/del")
    public String delete(Integer championId) {
        championSpellService.delete(championId);
        return "";
    }

    @RequestMapping("/upd")
    public String update(@RequestBody ChampionSpell spell) {
        championSpellService.update(spell);
        return "";
    }
    @ResponseBody
    @RequestMapping("/sel")
    public List<ChampionSpell> select(Integer championId) {
        return championSpellService.select(championId);
    }
}
